// 禁止回退
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
    history.pushState(null, null, document.URL);
});

// 检测回车事件
document.onkeydown = function (key) {
    if (key.keyCode === 13) {
        register();
    }
}

// 检测用户名是否存在
function register() {
    let userName = document.getElementById("userName").value;
    let userPass = document.getElementById("userPass").value;
    let confirmPass = document.getElementById("confirmPass").value;
    if (userName == "") {
        alert("请输入您要注册的用户名！");
    } else if (userPass == "") {
        alert("请设置用户名的密码！");
    } else if (confirmPass == "") {
        alert("请再次输入您的密码！");
    } else if (confirmPass != userPass) {
        alert("两次输入的密码不一样，请再次确认您的密码！")
        document.getElementById("confirmPass").value = "";
    } else {
        axios.post("//81.69.27.130/product/resgiter?password=" + userPass + "&username=" + userName)
            .then(function (response) {
                alert(response.data.msg);
            }, function (err) {
                console.log(err);
            })
    }
}